package com.amazon.inapp.purchasing;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import com.amazon.android.Kiwi;

final class KiwiResponseHandler
  implements ResponseHandler
{
  static final String HANDLER_THREAD_NAME = "KiwiResponseHandlerHandlerThread";
  private static final String KEY_REQUEST_ID = "requestId";
  private static final String KEY_RESPONSE_TYPE = "response_type";
  private static final String TAG = "KiwiResponseHandler";
  private final HandlerAdapter _handler = HandlerManager.getHandlerAdapter("KiwiResponseHandlerHandlerThread");

  public void handleResponse(Context paramContext, Intent paramIntent)
  {
    if (Logger.isTraceOn())
      Logger.trace("KiwiResponseHandler", "handleResponse");
    String str = paramIntent.getExtras().getString("response_type");
    if (str == null)
    {
      if (Logger.isTraceOn())
        Logger.trace("KiwiResponseHandler", "Invalid response type: null");
      label40: return;
    }
    while (true)
    {
      try
      {
        ResponseType localResponseType = ResponseType.valueOf(str);
        if (Logger.isTraceOn())
          Logger.trace("KiwiResponseHandler", "Found response type: " + localResponseType);
        int i = 1.$SwitchMap$com$amazon$inapp$purchasing$KiwiResponseHandler$ResponseType[localResponseType.ordinal()];
        localObject = null;
        switch (i)
        {
        default:
          if (localObject == null)
            break label40;
          this._handler.post((Runnable)localObject);
          return;
        case 1:
        }
      }
      catch (IllegalArgumentException localIllegalArgumentException)
      {
      }
      if (!Logger.isTraceOn())
        break;
      Logger.trace("KiwiResponseHandler", "Invlid response type: " + str);
      return;
      Object localObject = new PurchaseResponseHandlerRunnable(paramContext, paramIntent);
    }
  }

  private class PurchaseResponseHandlerRunnable extends KiwiResponseHandler.ResponseHandlerRunnable
  {
    public PurchaseResponseHandlerRunnable(Context paramIntent, Intent arg3)
    {
      super(paramIntent, localIntent);
    }

    public void run()
    {
      if (Logger.isTraceOn())
        Logger.trace("KiwiResponseHandler", "PurchaseResponseHandlerRunnable.run()");
      String str = getIntent().getExtras().getString("requestId");
      if (Logger.isTraceOn())
        Logger.trace("KiwiResponseHandler", "PurchaseResponseHandlerRunnable.run: requestId: " + str);
      if ((str != null) && (str.trim().length() > 0))
        Kiwi.addCommandToCommandTaskPipeline(new KiwiPurchaseResponseCommandTask(str));
    }
  }

  private abstract class ResponseHandlerRunnable
    implements Runnable
  {
    private final Context _context;
    private final Intent _intent;

    public ResponseHandlerRunnable(Context paramIntent, Intent arg3)
    {
      this._context = paramIntent;
      Object localObject;
      this._intent = localObject;
    }

    protected final Context getContext()
    {
      return this._context;
    }

    protected final Intent getIntent()
    {
      return this._intent;
    }
  }

  static enum ResponseType
  {
    static
    {
      item_response = new ResponseType("item_response", 1);
      updates_response = new ResponseType("updates_response", 2);
      ResponseType[] arrayOfResponseType = new ResponseType[3];
      arrayOfResponseType[0] = purchase_response;
      arrayOfResponseType[1] = item_response;
      arrayOfResponseType[2] = updates_response;
    }
  }
}

/* Location:           E:\android\Toy Defense 2_dex2jar.jar
 * Qualified Name:     com.amazon.inapp.purchasing.KiwiResponseHandler
 * JD-Core Version:    0.6.2
 */